<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title>编辑广告</title> 
    
    <!--[if lt IE 8]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
 
    <link rel="shortcut icon" href="/favicon.ico"> 
    <link href="/public/admin/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="/public/admin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/public/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/public/admin/css/animate.css" rel="stylesheet">
    <link href="/public/admin/css/style.css?v=4.0.0" rel="stylesheet">
    <link href="/public/admin/css/ourstyle.css?v=4.0.0" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="/public/webuploader/webuploader.css">
     <!-- kindeditor -->
    <script src="/public/kindeditor/kindeditor-all-min.js"></script>
    <script src="/public/kindeditor/lang/zh-CN.js"></script>
    <script src="/public/common/my.js"></script>
<style>
.tab-pane {
    display: block; position: absolute; opacity: 0; filter:Alpha(opacity=0);
}
.tab-pane-active {
    position: relative; opacity: 1; filter:Alpha(opacity=1);
}
</style>
<script language="javascript">
<!--
// KindEditor.ready(function(K) {
//     K.create('#img_alt', {
//         width : '100%',
//         resizeType : 1,
//         allowPreviewEmoticons : false,
//         allowImageUpload : false,
//         items : [
//             'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
//             'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
//             'insertunorderedlist', '|', 'emoticons', 'image', 'link'],
//         afterBlur:function(){this.sync();}
//     });
// });
-->
</script>
</head>

<body class="fixed-sidebar full-height-layout gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>广告内容</h5>
                </div>
                <div class="ibox-content">
                    <div class="row">
                            <form action="" method="post" id="adsConFrom" class="form-horizontal">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">所属栏目：</label>
                                    <div class="col-sm-8">
                                        <select class="form-control" name="kid">
                                        {foreach name="cat_select" item="cat"}
                                            {if $info['kid'] == $cat['id']}
                                            <option value="{$cat.id}" selected="selected">{$cat.kind_name}</option>
                                            {else/}
                                            <option value="{$cat.id}">{$cat.kind_name}</option>
                                            {/if}
                                        {/foreach}
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">广告标题：</label>
                                    <div class="col-sm-8">
                                        <input class="configInput form-control" name="title" minlength="2" type="text" value="{$info.title}" required="" aria-required="true" placeholder="填写广告标题">
                                    </div>
                                </div> 
                                <div class="form-group" style="display:none">
                                    <label class="col-sm-2 control-label">标语一：</label>
                                    <div class="col-sm-8">
                                        <input class="configInput form-control" name="title1" minlength="2" type="text" value="{$info.title1}" required="" aria-required="true" placeholder="">
                                    </div>
                                </div>   
                                <div class="form-group" style="display:none">
                                    <label class="col-sm-2 control-label">标语二：</label>
                                    <div class="col-sm-8">
                                        <input class="configInput form-control" name="title2" minlength="2" type="text" value="{$info.title2}" required="" aria-required="true" placeholder="">
                                    </div>
                                </div>  
                                <div class="form-group" style="display:none">
                                    <label class="col-sm-2 control-label">标语三：</label>
                                    <div class="col-sm-8">
                                        <input class="configInput form-control" name="title3" minlength="2" type="text" value="{$info.title3}" required="" aria-required="true" placeholder="">
                                    </div>
                                </div>  
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">其他属性：</label>
                                    <div class="col-sm-8">
                                        <div class="col-sm-10">
                                            <label class="checkbox-inline i-checks">
                                                <input type="checkbox" name="is_hide" value="1" {if $info['is_hide'] == 1} checked {/if}>禁用广告</label>
                                        </div>  
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">序号：</label>
                                    <div class="col-sm-8">
                                        <input class="configInput form-control" name="sort_order" type="text" class="configInput" value="{$info.sort_order}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">广告类型：</label>
                                    <div class="col-sm-8">
                                        <select class="form-control" name="tid" id="AdsType" onchange="ChangeType();">
                                            <option value="0" {if $info['tid'] == 0}selected="selected"{/if} >HTML代码</option>
                                            <option value="1" {if $info['tid'] == 1}selected="selected"{/if} >文字广告</option>
                                            <option value="2" {if $info['tid'] == 2}selected="selected"{/if} >图片广告</option>
                                            <option style="display:none" value="3" {if $info['tid'] == 3}selected="selected"{/if} >Flash广告</option>
                                            <option value="4" {if $info['tid'] == 4}selected="selected"{/if} >幻灯片广告</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group tab-pane" id="adstype_0">
                                    <label class="col-sm-2 control-label">HTML代码：</label>
                                    <div class="col-sm-8">
                                        <textarea class="form-control" id="txt_script" name="txt_script" rows="3" placeholder="请输入广告HTML代码"></textarea> 
                                    </div>
                                </div>
                                <div id="adstype_1" class="tab-pane">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">文字内容(必填)：</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" id="txt_txt" name="txt_txt" value="" placeholder="请输入文字广告的显示内容">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">文字链接(必填)：</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" id="txt_link" name="txt_link" value="" placeholder="请输入文字广告指向的 URL 链接地址">
                                        </div>
                                    </div>
                                    <div class="form-group" style="display:none">
                                        <label class="col-sm-2 control-label">文字样式(选填)：</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" id="txt_style" name="txt_style  " value="" placeholder="请输入文字广告的内容显示字体样式，即style内容">
                                        </div>
                                    </div>
                                </div>
                                <div id="adstype_2" class="tab-pane">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">图片：</label>
                                        <div class="col-sm-8">
                                            <div class="input-group">
                                                <input id="img_img" name="img_img" maxlength="250" type="text" class="form-control" placeholder="请输入图片广告的图片调用地址" value="">
                                                <span class="input-group-btn">
                                                    <button type="button" class="btn btn-primary" onclick="BrowseServer('img_img')">
                                                        选择图片
                                                    </button>
                                                </span>
                                           </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">链接地址：</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" id="img_link" name="img_link" value="" placeholder="请输入图片广告图片链接地址">
                                        </div>
                                    </div>
                                    <div class="form-group" style="display:none">
                                        <label class="col-sm-2 control-label">图片宽度(选填)：</label>
                                        <div class="col-sm-8">
                                            <input type="number" class="form-control" id="img_width" name="img_width" value="" placeholder="请输入图片广告的宽度，单位为像素">
                                        </div>
                                    </div>
                                    <div class="form-group" style="display:none">
                                        <label class="col-sm-2 control-label">图片高度(选填)：</label>
                                        <div class="col-sm-8">
                                            <input type="number" class="form-control" id="img_height" name="img_height" value="" placeholder="请输入图片广告的高度，单位为像素">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">图片描述：</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" id="img_alt" name="img_alt" value="" placeholder="请输入图片广告图片描述">
                                        </div>
                                    </div>
                                    <!-- <div class="form-group">
                                        <label class="col-sm-2 control-label">图片描述：</label>
                                        <div class="col-sm-8">
                                            <textarea id="img_alt" name="img_alt" rows="2" cols="20"></textarea>
                                        </div>
                                    </div> -->
                                </div>
                                <div id="adstype_3" class="tab-pane">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">Flash 地址(必填)：</label>
                                        <div class="col-sm-8">
                                            <div class="input-group">
                                                <input type="text" class="form-control" id="flash_swf" name="flash_swf" value="" placeholder="请输入 Flash 广告的调用地址">
                                                <span class="input-group-btn">
                                                    <button type="button" class="btn btn-primary" onclick="BrowseServer('flash_swf')">
                                                         选择Flash
                                                    </button>
                                                </span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">Flash 宽度(必填)：</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" id="flash_width" name="flash_width" value="" placeholder="请输入 Flash 广告的宽度，单位为像素">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">Flash 高度(选填)：</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" id="flash_height" name="flash_height" value="" placeholder="请输入 Flash 广告的高度，单位为像素">
                                        </div>
                                    </div>
                                </div>
                                <div id="adstype_4" class="tab-pane">
                                    <div class="form-group" style="display:none">
                                        <label class="col-sm-2 control-label">幻灯片宽度(必填)：</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" id="slide_width" name="slide_width" value="" placeholder="请输入幻灯片广告的宽度，单位为像素">
                                        </div>
                                    </div>
                                    <div class="form-group" style="display:none">
                                        <label class="col-sm-2 control-label">幻灯片高度(必填)：</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" id="slide_height" name="slide_height" value="" placeholder="请输入幻灯片广告的高度，单位为像素">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">幻灯片详情：</label>
                                        <div class="col-sm-8">
                                            <table class="table table-hover">
                                                <thead>
                                                    <tr>
                                                        <th>图片标题</th>
                                                        <th style="width:30%">图片</th>
                                                        <th>链接地址</th>
                                                        <th>排序</th>
                                                        <th style="width:80px">操作</th>
                                                    </tr>
                                                </thead>
                                                <tbody id="SildeImgs">
                                                    <tr>
                                                        <td><input type="text" class="form-control" id="slide_alt_0" name="slide_alt[]" value="" placeholder="图片标题"></td>
                                                        <td><div class="input-group"><input type="text" class="form-control upload-path" id="slide_img_0" name="slide_img[]" value="" placeholder="图片地址"><span class="input-group-btn"><button type="button" class="btn btn-primary" onclick="BrowseServer('slide_img_0')"><i class="fa fa-search"></i></button></span></div></td>
                                                        <td><input type="text" class="form-control" id="slide_link_0" name="slide_link[]" value="" placeholder="链接地址"></td>
                                                        <td><input type="text" class="form-control" id="slide_order_0" name="slide_order[]" value="50" placeholder="序号"></td>
                                                        <td><button type="button" class="btn btn-sm btn-success" onClick="addSlideRow();"><i class="fa fa-plus-square"></i>添加</button></td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>


                                </div>

                                <div class="hr-line-dashed"></div>
                                <div class="form-group">
                                    <div class="col-sm-4 col-sm-offset-2">
                                        <input type="hidden" name="act" value="{$act}">
                                        <input type="hidden" name="id" value="{$info.id}"> 
                                        <input type="hidden" name="jsoncontent" id="jsoncontent" value="'{$info.content}'"> 
                                        <button class="btn btn-primary" onclick="ajax_submit_form('adsConFrom','{:url('Other/adsEditHandle')}')" type="button">保存</button>
                                    </div>
                                </div> 
                    	    </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

    <!-- 全局js -->
    <!-- <script src="/public/admin/js/jquery.min.js?v=2.1.4"></script> -->
    <script src="/public/admin/js/jQuery-2.1.4.min.js"></script>
    <script src="/public/admin/js/bootstrap.min.js?v=3.3.5"></script>
	<!-- 自定义js -->
    <script src="/public/admin/js/content.js?v=1.0.0"></script>
    <script src="/public/admin/js/plugins/layer/layer.min.js"></script>
    <script src="/public/admin/plugins/laydate/laydate.js"></script>
    <script src="/public/admin/js/article.js"></script> 
    <!-- iCheck -->
    <script src="/public/admin/js/plugins/iCheck/icheck.min.js"></script>
    <!-- webuploader -->
    <script type="text/javascript" src="/public/webuploader/webuploader.nolog.js"></script>
    <script src="/public/admin/plugins/ckfinder/ckfinder.js"></script>
    <!-- plupload -->
    <script type="text/javascript" src="/public/plupload/plupload.full.min.js"></script>
    <script type="text/javascript" src="/public/admin/js/webupload.js"></script>
    <script>
        var index = parent.layer.getFrameIndex(window.name);
        function closethisdialog() {
            parent.layer.close(index);
        }
        function ChangeType() {
            var styles, key, val;
            val = $('#AdsType').val();
            styles = new Array('0', '1', '2', '3', '4');
            for (key in styles) {
                if (styles[key] == val) {
                    // $("#adstype_" + styles[key]).removeClass('hide');
                    $("#adstype_" + styles[key]).removeClass('tab-pane');
                    $("#adstype_" + styles[key]).addClass('tab-pane-active');
                } else {
                    $("#adstype_" + styles[key]).removeClass('tab-pane-active');
                    $("#adstype_" + styles[key]).addClass('tab-pane');
                }
            }
        }
        var htmlText = '<tr id="slideTR_{0}">';
        htmlText += '<td><input type="text" class="form-control" id="slide_alt_{0}" name="slide_alt[]" value="" placeholder="图片标题"></td>';
        htmlText += '<td><div class="input-group"><input type="text" class="form-control upload-path" id="slide_img_{0}" name="slide_img[]" value="" placeholder="图片地址"><span class="input-group-btn"><button type="button" class="btn btn-primary" onclick="BrowseServer(\'slide_img_{0}\')"><i class="fa fa-search"></i></button></span></div></td>';
        htmlText += '<td><input type="text" class="form-control" id="slide_link_{0}" name="slide_link[]" value="" placeholder="链接地址"></td>';
        htmlText += '<td><input type="text" class="form-control" id="slide_order_{0}" name="slide_order[]" value="50" placeholder="序号"></td>';
        
        htmlText += '<td><button type="button" class="btn btn-sm btn-danger" onclick="delmySlideRow({0})"><i class="fa fa-minus-square"></i> 删除</button></td></tr>';
        var items = 1;

        function addSlideRow() {
            var lastitem = items - 1;
            var newHtmlTr = htmlText.replace(/\{0\}/g, items);
            $('#SildeImgs').append(newHtmlTr);
            items += 1;
        }
        function delmySlideRow(id) {
            $("#slideTR_" + id).remove();
        }
 
        var jsonstr2 = '<?php echo $info['content'] ?>';
        $(function () {
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });
            // DoPost("addAdsForm");
            ChangeType();
            FillAds($('#AdsType').val(),''+jsonstr2+'');
        })
        //JS加载广告内容
        function FillAds(tid, content) {
            // var json = eval(content);
            var json = eval("("+content+")");
            var tbody = '';
            // alert(content);
            switch (tid) {
                case '0': //代码
                    $('#txt_script').val(json.script);  
                    break;
                case '1': //文字类型
                    $('#txt_txt').val(json.txt);
                    $('#txt_link').val(json.link);
                    $('#txt_style').val(json.style);
                    break;
                case '2': //图片类
                    $('#img_img').val(json.image);
                    $('#img_link').val(json.link);
                    if(json.width !=0){
                        $('#img_width').val(json.width);
                    }
                    if(json.height !=0){
                        $('#img_height').val(json.height);
                    }
                    $('#img_alt').val(json.alt);
                    break;
                case '3'://Flash类型
                    $('#flash_swf').val(json.swf);
                    $('#flash_height').val(json.height);
                    $('#flash_width').val(json.width);
                    break;
                case '4'://幻灯片
                    for(i=0;i<json.length;i++)
                    {
                        if(i ==0)
                        {
                            $("#slide_width").val(json[0].width);
                            $("#slide_height").val(json[0].height);
                        }
                        else
                        {
                            addSlideRow();//增加一行
                        }
                        $("#slide_img_"+i).val(json[i].image);
                        $("#slide_link_"+i).val(json[i].link);
                        $("#slide_alt_"+i).val(json[i].alt);
                        $("#slide_order_"+i).val(json[i].order);
                    }
                    break;
            }
        }

    </script>

</body>
</html>
